import sys
import os
sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))

import threading
import asyncio
from agents.agent import langgraph_mcp_agent
from agents.class_agent import LangGraphMCPAgent
from langgraph.types import Command


async def main():
    agent = LangGraphMCPAgent()
    graph = await agent.initialize()
    current_thread_id = threading.current_thread().ident
    config = {"configurable": {"thread_id": str(current_thread_id)}}
    print("config1:", config)

    # 使用异步输入处理
    # user_input = await asyncio.to_thread(input, "User: ")
    # 异步处理流更新
    result1 = await graph.ainvoke(
        {"messages": [{"role": "user", "content": "帮282696进行6月的签卡"}]},
        config,
    )
    # print("main:", event)
    print("result1:", result1)
    print(result1['__interrupt__'])

    result2 = await graph.ainvoke(Command(resume="approve"), config=config)
    # print("result2:", result2)


if __name__ == "__main__":
    asyncio.run(main())
